﻿using iMES.Basedata.IRepository.Basicdata;
using iMES.Basedata.IServices;
using iMES.Custom.Services;
using iMES.Entity.DomainModels;
using iMES.Warehouse.IRepositories;
using iMES.Warehouse.IServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace iMES.WebApi.Controllers
{

    public partial class Basicdata_ProcessController
    {
        private readonly IBasicdata_ProcessService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IBasicdata_ProcessListRepository _wareHouseBillListRepository;

        [ActivatorUtilitiesConstructor]
        public Basicdata_ProcessController(
            IBasicdata_ProcessService service,
            IHttpContextAccessor httpContextAccessor,
            IBasicdata_ProcessListRepository wareHouseBillListRepository
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
            _wareHouseBillListRepository = wareHouseBillListRepository;
        }

        /// <summary>
        /// 获取工序数据采集信息列表
        /// </summary>
        /// <param name="Process_Id">工序</param>
        /// <returns></returns>
        [Route("getDetailRows"), HttpGet]
        public async Task<IActionResult> GetDetailRows(int Process_Id)
        {
            var rows = await _wareHouseBillListRepository.FindAsIQueryable(x => x.Process_Id == Process_Id)
                  .ToListAsync();
            return JsonNormal(rows);
        }
        /// <summary>
        /// 获取工序数据采集信息列表
        /// </summary>
        /// <param name="Process_Id">工序</param>
        /// <returns></returns>
        [Route("getProcessListByLineID"), HttpGet]
        public JsonResult GetProcessListByLineID(int ProcessLine_Id)
        {
            return JsonNormal(_service.GetProcessListByLineID(ProcessLine_Id));
        }
    }
}
